<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>临床输血</title>
    <link rel="shortcut icon" type="image/x-icon" href="/img/favicon.ico">
    <link rel="stylesheet" href="/element-theme/blue/index.css">
</head>
<body>

<div class="data-manage-table">
    <template>
        <el-form ref="form" :inline="true" style="padding:20px 20px 0 20px;">
            <el-form-item label="申请单号">
                <el-input v-model="pagination.transfusionNumber" placeholder="请输入输血申请单号"></el-input>
            </el-form-item>

            <el-form-item label="身份证号">
                <el-input v-model="pagination.patientIdcard" clearable placeholder="请输入病人身份证号"></el-input>
            </el-form-item>

            <el-form-item label="血液成分">
                <el-select v-model="pagination.transfusionType" placeholder="请选择或输入血液成分" clearable filterable @blur="selectBlur"
                           @clear = "selectClearComponent" @change="selectChangeComponent">
                    <el-option v-for="(item,index) in transfusionTypeList" :key="item.code" :label="item.composition" :value="item.code">
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="血量">
                <el-select v-model="pagination.transfusionVolume" clearable placeholder="请选择血量">
                    <el-option v-for="item in transfusionVolumeList" :key="item.code" :label="item.size" :value="item.code">
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="getByQueryPage(1)">搜索</el-button>
            </el-form-item>

            <el-form-item>
                <el-button type="info" @click="getByQueryPage()">重置</el-button>
            </el-form-item>

            <el-form-item>
                <el-button type="danger" @click="batchDelete()">批量删除</el-button>
            </el-form-item>

            <el-table ref="clinicTable" :data="clinicData" style="width: 100%" border
                      :header-cell-style="{'text-align': 'center','background': '#eef1f6'}" highlight-current-row fit>
                <el-table-column type="selection"></el-table-column>
                <el-table-column prop="transfusionNumber" label="输血申请单号" align="center">
                    <template slot-scope="scope">
                        <el-button type="text"  @click="viewInfo(scope.row)">{{ scope.row.transfusionNumber }}</el-button>
                    </template>
                </el-table-column>
                <el-table-column prop="patientIdcard" label="病人身份证号" align="center"></el-table-column>
                <el-table-column prop="transfusionVolume" label="血量" align="center">
                    <template slot-scope="scope">
                        {{ getBloodSizeName(scope.row.transfusionVolume) }}
                    </template>
                </el-table-column>
                <el-table-column prop="transfusionType" label="输血类型" align="center">
                    <template slot-scope="scope">
                        {{ getTransfusionTypeName(scope.row.transfusionType) }}
                    </template>
                </el-table-column>

                <!--相关操作-->
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button size="mini" type="primary" @click="Match(scope.row)" align="center">分配</el-button>
                        <el-dialog title="配血信息确认" :visible.sync="bloodInfoFormVisible" :modal="false">
                            <el-descriptions :content-style="rowCenter" :label-style="rowCenter" class="margin-top" :column="2"  border>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                        血液ID
                                    </template>
                                    {{ bloodInfoForm.id}}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                        血液编号
                                    </template>
                                    {{ bloodInfoForm.bloodId }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label">
                                        血装编号条码
                                    </template>
                                    {{ bloodInfoForm.barcode }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                        扩展码
                                    </template>
                                    {{ bloodInfoForm.extendCode }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                        血液成分
                                    </template>
                                    {{ bloodInfoForm.bloodComponent }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label">
                                        血量
                                    </template>
                                    {{ bloodInfoForm.bloodCount }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                        ABO血型
                                    </template>
                                    {{ bloodInfoForm.aboBloodType }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                        RH血型
                                    </template>
                                    {{ bloodInfoForm.rhBloodType }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label">
                                        血液位置
                                    </template>
                                    {{ bloodInfoForm.bloodLocation }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label">
                                        状态
                                    </template>
                                    {{ bloodInfoForm.state }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                        入库金额
                                    </template>
                                    {{ bloodInfoForm.inboundAmount }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                        血液金额
                                    </template>
                                    {{ bloodInfoForm.bloodAmount }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                        失效时间
                                    </template>
                                    {{ bloodInfoForm.failureTime }}
                                </el-descriptions-item>
                                <el-descriptions-item>
                                    <template slot="label" align="center" >
                                        采集时间
                                    </template>
                                    {{ bloodInfoForm.collectTime }}
                                </el-descriptions-item>
                            </el-descriptions>
                            <div slot="footer" class="dialog-footer" align="center">
                                <el-button type="danger" @click="cancel()">取消分配</el-button>
                                <el-button type="primary" @click="determine()">确定分配</el-button>
                            </div>
                        </el-dialog>
                    </template>
                </el-table-column>
            </el-table>


            <!--分页组件-->
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-sizes="[5,10,15]"
                        :page-size="pagination.pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="pagination.total"
                        style="text-align: center; margin-top: 20px;">
                </el-pagination>
            </div>

            <el-dialog title="临床输血申请" center :visible.sync="dialogClinicVisible" :modal="false" width="60%">
                <el-descriptions :content-style="rowCenter" :label-style="rowCenter" class="margin-top"  :column="3"   border>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            病历号
                        </template>
                        {{ clinicSample.medicalRecordNumber}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            临床输血申请单号
                        </template>
                        {{ clinicSample.transfusionNumber}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            临床诊断
                        </template>
                        {{ clinicSample.clinicalDiagnosis}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            输血目的
                        </template>
                        {{clinicSample.transfusionPurpose}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            输血成分
                        </template>
                        {{clinicSample.transfusionType}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            申请输血量
                        </template>
                        {{clinicSample.transfusionVolume}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            预定输血日期
                        </template>
                        {{ clinicSample.scheduledTransfusionTime}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            辐照血
                        </template>
                        {{ clinicSample.isIrradiationBlood}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            过滤血
                        </template>
                        {{ clinicSample.isFilteringBlood}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            复检
                        </template>
                        {{ clinicSample.isRecheck }}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            接受标本时间
                        </template>
                        {{ clinicSample.acceptSampleTime}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            申请医生
                        </template>
                        {{clinicSample.applyDoctor }}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            主治医师
                        </template>
                        {{ clinicSample.attendingPhysician}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            申请日期
                        </template>
                        {{clinicSample.applyTime }}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            输血同意书
                        </template>
                        {{ clinicSample.isSignConsentForm}}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            受血者血液标本
                        </template>
                        {{clinicSample.recipientSpecimen }}</el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            接收标本时间
                        </template>
                        {{ clinicSample.receiveSampleTime}}</el-descriptions-item>
                </el-descriptions>

    </template>
</div>


<script src="/js/vue.min.js"></script>
<script src = "/js/2.15.12/index.js"></script>
<link href = "/css/2.15.12/index.css" rel="stylesheet">
<script src="/plugins/axios-0.27.2/axios.min.js"></script>
<script src="/icons/iconfont.js"></script>
<script src="/js/httpVueLoader.js"></script>
<script>Vue.prototype.$ELEMENT = { size: 'medium' };</script>
<script>(
    function () {
        new Vue({
            el: '.data-manage-table',
            data() {
                return {
                    // 描述列表文字居中
                    rowCenter:{
                        "text-align":"center"
                    },
                    // 测试能不能拼接
                    test : '',

                    //血液状态列表
                    stateList : '',

                    // 临床输血详情描述列表开关
                    dialogClinicVisible : false,

                    // 临床输血详情描述列表
                    clinicSample : [],

                    // abo血型
                    aboBloodTypeList : '',

                    // rh血型
                    rhBloodTypeList : '',

                    //血液成分列表
                    bloodComponentList : '',

                    // 血袋位置列表
                    bloodLocationList : '',

                    //血液来源列表
                    bloodSourceList : '',

                    // 输血量列表
                    transfusionVolumeList : '',

                    //输血类型列表
                    transfusionTypeList : '',

                    //分页相关信息
                    pagination: {
                        currentPage : 1, //当前页码
                        pageSize : 5, //每页显示记录数
                        total : 0, //总记录数
                        //查询条件
                        transfusionNumber: '', //输血申请单号
                        patientIdcard : '',
                        transfusionType : '',
                        transfusionVolume : '',
                    },

                    //嵌套dialog表格状态
                    bloodInfoFormVisible : false,

                    //信件嵌套表格的状态
                    textTableVisble : false,

                    //确认配血信息表单状态
                    dialogFormVisible : false,

                    // 配血确认信息表格
                    bloodInfoForm : {
                        id : '',
                        bloodId : '',
                        barcode : '',
                        extendCode : '',
                        bloodComponent : '',
                        bloodCount : '',
                        aboBloodType : '',
                        rhBloodType : '',
                        failureTime : '',
                        collectTime : '',
                        bloodSource : '',
                        state : '',
                        bloodLocation : '',
                        bloodAmount : '',
                        batchNumber : '',
                        inboundAmount : '',
                    },

                    // 是否能够进行配血
                    checkDispenseState : false,

                    //表格信息
                    clinicData: [],

                    //匹配表格信息
                    matchBlood: [],

                    //待分配血液信息
                    dispenseBlood : [],

                    // 需要通过输血更改的整体输血信息表里的血液状态
                    transfusionNumberIndex : '',

                    // 添加配血记录需要用的
                    patientIdcardIndex : '',

                    //信件表格信息
                    textTableData : [],

                    //医生消息条数
                    textnum : 0,

                    // 血液匹配信息分页
                    currentPageBlood: 1,
                    pagesizeBlood: 1,
                }
            },

            //自动触发写入的函数
            created() {
                this.getByQueryPage();
            },

            mounted() {
                this.getBloodLocation();
                this.getBloodSize();
                this.getBloodSource();
                this.getState();
                this.getAboBloodType();
                this.getRhBloodType();
                this.getBloodComponent();
                this.getTransfusionType();
            },

            methods: {
                selectBlur(e){
                    if (e.target.value !== ''){
                        this.pagination.state = e.target.value;
                        this.$forceUpdate() //强制更新
                    }
                },

                // 清空血液成分
                selectClearComponent(){
                    this.pagination.transfusionType = ''
                    this.$forceUpdate();
                },

                // 输入血液成分
                selectChangeComponent(val){
                    this.pagination.transfusionType = val
                    this.$forceUpdate();
                },
                //批量删除
                batchDelete() {
                    if(JSON.parse(JSON.stringify(this.$refs.clinicTable.selection)).length==0){
                        this.$notify({
                            title: '温馨提示：',
                            message: '您未选中数据，请重新操作！！！',
                            type: 'warning'
                        });
                        return;
                    }
                    let checkArr = JSON.parse(JSON.stringify(this.$refs.clinicTable.selection));  // 存储了勾选到的数据
                    var ids=new Array()
                    for(var i=0;i<checkArr.length;i++){
                        ids[i]=checkArr[i].id;
                    }
                    console.log("打印所选编号")
                    console.log(ids)
                    // let data={ids:ids}
                    //批量删除
                    this.$confirm('确定删除这些数据吗, 是否继续?', '批量删除', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        axios({
                            url: '/transfusionClinic/normal/batchDelete1',
                            method: 'put',
                            dataType: 'json',
                            data:ids
                        }).then(res => {
                            if (res.data.code === '200') {
                                this.$notify({
                                    tile: '温馨提示',
                                    message: '批量删除成功！！！',
                                    type: 'success'
                                })
                                this.getByQueryPage(0);
                            } else {
                                this.$notify({
                                    tile: '警告',
                                    message: '删除出错',
                                    type: 'warning'
                                })
                            }
                        }).catch(err => {
                            this.$notify.error({
                                title: '错误',
                                message: '删除失败',
                            })
                        });
                    }).catch(() => {
                        this.$message({
                            type: 'info',
                            message: '已取消删除'
                        });
                    });
                },
                //分页查询
                getByQueryPage:function(flag){
                    if (flag != 1) {
                        this.pagination.transfusionNumber = '';
                        this.pagination.patientIdcard = '';
                        this.pagination.transfusionType = '';
                        this.pagination.transfusionVolume = '';
                        this.pagination.currentPage = 1;
                    }
                    axios.get('/transfusionClinic/normal/lrz/' + this.pagination.currentPage + '/' + this.pagination.pageSize,
                        {
                            params:{
                                transfusionNumber : this.pagination.transfusionNumber,
                                aboBloodType : this.pagination.aboBloodType,
                                rhBloodType : this.pagination.rhBloodType,
                                patientIdcard : this.pagination.patientIdcard,
                                transfusionType : this.pagination.transfusionType,
                                transfusionVolume : this.pagination.transfusionVolume,
                            }
                        }).then((res)=>{
                        if (res.data.code === '200') {
                            this.pagination.pageSize = res.data.data.size;
                            this.pagination.currentPage = res.data.data.current;
                            this.pagination.total = res.data.data.total;
                            this.clinicData = res.data.data.records;
                        } else{
                            this.$message.success('查询失败');
                        }
                    });
                },

                // 分页查询 每页显示多少条数据
                handleSizeChange:function(pageSize){
                    this.pagination.pageSize = pageSize;
                    this.getByQueryPage(1);
                },

                //分页查询 切换页码
                handleCurrentChange:function(currentPage){
                    this.pagination.currentPage = currentPage;
                    //执行查询
                    this.getByQueryPage(1);
                },

                viewInfo(row){
                    // this.clinicSample = row;
                    this.clinicSample.medicalRecordNumber = row.medicalRecordNumber
                    this.clinicSample.transfusionNumber = row.transfusionNumber
                    this.clinicSample.clinicalDiagnosis = row.clinicalDiagnosis
                    this.clinicSample.transfusionPurpose = row.transfusionPurpose
                    this.clinicSample.scheduledTransfusionTime = row.scheduledTransfusionTime
                    this.clinicSample.isIrradiationBlood = row.isIrradiationBlood
                    this.clinicSample.isFilteringBlood = row.isFilteringBlood
                    this.clinicSample.isRecheck = row.isRecheck
                    this.clinicSample.acceptSampleTime = row.acceptSampleTime
                    this.clinicSample.applyDoctor = row.applyDoctor
                    this.clinicSample.applyTime = row.applyTime
                    this.clinicSample.isSignConsentForm = row.isSignConsentForm
                    this.clinicSample.recipientSpecimen = row.recipientSpecimen
                    this.clinicSample.receiveSampleTime = row.receiveSampleTime
                    this.clinicSample.transfusionType = this.getBloodComponentName(row.transfusionType);
                    this.clinicSample.transfusionVolume = this.getBloodSizeName(row.transfusionVolume);
                    this.clinicSample.bloodType = this.getAboBloodName(row.bloodType);
                    this.clinicSample.rhd = this.getRhBloodName(row.rhd);
                    this.dialogClinicVisible = true;
                },

                // 匹配符合条件的血液信息
                Match(row){
                    this.transfusionNumberIndex = row.transfusionNumber
                    this.patientIdcardIndex = row.patientIdcard
                    // 分配前是否有分配记录
                    axios.get('/transfusionApplicationInformation/normal/checkRecords', {
                        params : {
                            patientIdcard : row.patientIdcard,
                            transfusionNumber : row.transfusionNumber,
                        }
                    }).then((res)=>{
                        // 代表没有记录,可以开始匹配
                        if (res.data.code === '200'){
                            // 首先先获得病人血型信息
                            axios.get('/transfusionClinic/normal/getBloodType', {
                                params:{
                                    patientIdcard : row.patientIdcard,
                                }
                            }).then((res)=>{
                                if (res.data.code === '200'){
                                    axios.get('/bloodInformation/normal/getBloodInfo', {
                                        params : {
                                            aboBloodType : row.aboBloodType,
                                            rhBloodType : row.rhBloodType,
                                            bloodCount : row.transfusionVolume,
                                            bloodComponent : row.transfusionType,
                                            collectTime : this.getNowTime(),
                                            failureTime : this.getNowTime(),
                                        }
                                    }).then((res)=>{
                                        if (res.data.code === '200'){
                                            console.log(res.data.data)
                                            this.bloodInfoForm.id = res.data.data.id;
                                            this.bloodInfoForm.bloodId = res.data.data.bloodId;
                                            this.bloodInfoForm.barcode = res.data.data.barcode;
                                            this.bloodInfoForm.extendCode = res.data.data.extendCode;
                                            this.bloodInfoForm.bloodComponent = this.getBloodComponentName(res.data.data.bloodComponent);
                                            this.bloodInfoForm.bloodCount = this.getBloodSizeName(res.data.data.bloodCount);
                                            this.bloodInfoForm.aboBloodType = this.getAboBloodName(res.data.data.aboBloodType);
                                            this.bloodInfoForm.rhBloodType = this.getRhBloodName(res.data.data.rhBloodType);
                                            this.bloodInfoForm.failureTime = res.data.data.failureTime;
                                            this.bloodInfoForm.collectTime = res.data.data.collectTime;
                                            this.bloodInfoForm.state = this.getStateName(res.data.data.state);
                                            this.bloodInfoForm.bloodLocation = this.getBloodLocationName(res.data.data.bloodLocation);
                                            this.bloodInfoForm.bloodAmount = res.data.data.bloodAmount;
                                            this.bloodInfoForm.inboundAmount = res.data.data.inboundAmount;
                                            this.bloodInfoForm.bloodSource = this.getBloodSourceName(res.data.data.bloodSource);
                                            this.bloodInfoForm.batchNumber = res.data.data.batchNumber;
                                            this.bloodInfoFormVisible = true
                                        } else{
                                            this.$notify({
                                                title : '消息',
                                                message : res.data.msg,
                                                type : 'warning'
                                            })
                                        }
                                    })
                                } else {
                                    this.$notify({
                                        title : '消息',
                                        message : res.data.msg,
                                        type : 'warning'
                                    })
                                }
                            })
                        } else{
                            this.$notify({
                                title : '消息',
                                message : res.data.msg,
                                type : 'warning'
                            })
                        }
                    })
                },


                // 发血
                determine(){
                    // 关闭对话表格
                    this.bloodInfoFormVisible = false;
                    // 更改血液信息表信息状态
                    axios({
                        url : ' /bloodInformation/normal/setBloodInfoState',
                        method : 'put',
                        data : JSON.stringify({
                            bloodId : this.bloodInfoForm.bloodId,
                            state : '28', // 28代表的待取血
                        }),
                        headers : {
                            'Content-Type' : 'application/json;charset=UTF-8'
                        }
                    }).then((res)=>{
                        if (res.data.code === '200'){
                            this.$notify({
                                title : '消息',
                                message : res.data.data,
                                type : 'success'
                            })
                        }else {
                            this.$notify({
                                title : '消息',
                                message : '未找到匹配血液信息',
                                type : 'warning'
                            })
                        }
                    })
                    // 更改整体输血表状态信息
                    axios({
                        url : ' /overall/normal/setOverallBloodState',
                        method : 'put',
                        data : JSON.stringify({
                            transfusionNumber : this.transfusionNumberIndex,
                            state : '1', // 1代表待取血
                        }),
                        headers : {
                            'Content-Type' : 'application/json;charset=UTF-8'
                        }
                    }).then((res)=>{
                        if (res.data.code === '200'){
                            this.$notify({
                                title : '消息',
                                message : res.data.data,
                                type : 'success'
                            })
                        }else {
                            this.$notify({
                                title : '消息',
                                message : '未找到匹配血液信息',
                                type : 'warning'
                            })
                        }
                    })

                    var patientId;
                    axios.get('/patient/normal/getPatientId',{
                        params : {
                            patientIdcard : this.patientIdcardIndex
                        }
                    }).then((res)=>{
                        patientId = res.data.data;
                        //添加配血记录
                        axios({
                            url : '/transfusionApplicationInformation/normal/addRecord',
                            method : 'post',
                            data : JSON.stringify({
                                transfusionNumber : this.transfusionNumberIndex,
                                patientId : patientId,
                                bloodComponent : this.getBloodComponentCode(this.bloodInfoForm.bloodComponent),
                                aboBloodType : this.getAboBloodCode(this.bloodInfoForm.aboBloodType),
                                rhBloodType : this.getRhBloodCode(this.bloodInfoForm.rhBloodType),
                                bloodCount : this.getBloodSizeCode(this.bloodInfoForm.bloodCount),
                                bloodNumber : this.bloodInfoForm.bloodId,
                                dispenseFlag : 0,
                            }),
                            headers : {
                                'Content-Type' : 'application/json;charset=UTF-8'
                            }
                        }).then((res)=>{
                            if (res.data.code === '200'){
                                this.$notify({
                                    title: '消息',
                                    message: res.data.data,
                                    type: 'success'
                                })
                                //刷新页面
                                this.getByQueryPage();
                            } else {
                                this.$notify({
                                    title: '消息',
                                    message: '响应失败',
                                    type: 'warning'
                                })
                            }
                        })
                    })
                },

                // 发血取消按钮
                cancel(){
                    this.bloodInfoForm.id = '';
                    this.bloodInfoForm.bloodId = '';
                    this.bloodInfoForm.patientIdcard = '';
                    this.bloodInfoForm.barcode = '';
                    this.bloodInfoForm.extendCode = '';
                    this.bloodInfoForm.bloodComponent = '';
                    this.bloodInfoForm.bloodCount = '';
                    this.bloodInfoForm.aboBloodType = '';
                    this.bloodInfoForm.rhBloodType = '';
                    this.bloodInfoForm.failureTime = '';
                    this.bloodInfoForm.collectTime = '';
                    this.bloodInfoForm.state = '';
                    this.bloodInfoForm.bloodLocation = '';
                    this.bloodInfoForm.bloodAmount = '';
                    this.bloodInfoForm.batchNumber = '';
                    this.bloodInfoForm.inboundAmount = '';
                    // 关闭对话表格
                    this.bloodInfoFormVisible = false;
                },

                // 获取状态字典
                getState(){
                    axios.get('/state/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200'){
                                this.stateList = res.data.data
                            } else {
                                this.$notify.error({
                                    title : '错误',
                                    message : '获取数据失败'
                                })
                            }
                        })
                },

                // 将表格中的State字段的code转换成name
                getStateName(code){
                    for (var i=0;i<this.stateList.length;i++){
                        if (this.stateList[i].code == code){
                            return this.stateList[i].state
                        }
                    }
                },

                // 获取血液来源字典
                getBloodSource(){
                    axios.get('/bloodSource/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200') {
                                this.bloodSourceList = res.data.data
                            } else {
                                this.$notify.error({
                                    title: '错误',
                                    message: '获取数据失败',
                                })
                            }
                        })
                },

                // 将表格中aboBloodType字段的code转换成name
                getBloodSourceName(code){
                    for (var i = 0; i < this.bloodSourceList.length; i++) {
                        if (this.bloodSourceList[i].code == code) { //dictValue，dictLabel保持和上面定义一致
                            return this.bloodSourceList[i].source;
                        }
                    }
                },

                // 获取血量字典
                getBloodSize(){
                    axios.get('/bloodSize/normal/getName1')
                        .then((res)=>{
                            if (res.data.code === '200') {
                                this.transfusionVolumeList = res.data.data
                            } else {
                                this.$notify.error({
                                    title: '错误',
                                    message: '获取数据失败',
                                })
                            }
                        })
                },

                // 将表格中bloodCount字段的code转换成size
                getBloodSizeName(code){
                    for (var i = 0; i < this.transfusionVolumeList.length; i++) {
                        if (this.transfusionVolumeList[i].code == code) { //dictValue，dictLabel保持和上面定义一致
                            return this.transfusionVolumeList[i].size;
                        }
                    }
                },

                // 将表格中bloodCount字段的size转换成code
                getBloodSizeCode(name){
                    for (var i = 0; i < this.transfusionVolumeList.length; i++) {
                        if (this.transfusionVolumeList[i].size == name) { //dictValue，dictLabel保持和上面定义一致
                            return this.transfusionVolumeList[i].code;
                        }
                    }
                },

                // 获取输血申请字典
                getTransfusionType(){
                    axios.get('/bloodComposition/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200'){
                                this.transfusionTypeList = res.data.data
                            } else {
                                this.$notify.error({
                                    title : '错误',
                                    message : '获取数据失败'
                                })
                            }
                        })
                },

                // 将表格中的transfusionType字段的code转换成name
                getTransfusionTypeName(code){
                    for (var i=0;i<this.transfusionTypeList.length;i++){
                        if (this.transfusionTypeList[i].code == code){
                            return this.transfusionTypeList[i].composition
                        }
                    }
                },

                // 获取abo血型字典
                getAboBloodType(){
                    axios.get('/aboType/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200') {
                                this.aboBloodTypeList = res.data.data
                            } else {
                                this.$notify.error({
                                    title: '错误',
                                    message: '获取数据失败',
                                })
                            }
                        })
                },

                // 将表格中aboBloodType字段的code转换成name
                getAboBloodName(code){
                    for (var i = 0; i < this.aboBloodTypeList.length; i++) {
                        if (this.aboBloodTypeList[i].code == code) { //dictValue，dictLabel保持和上面定义一致
                            return this.aboBloodTypeList[i].name;
                        }
                    }
                },

                // 将表格中的aboBloodType字段的name转换成code
                getAboBloodCode(name){
                    for (var i = 0; i < this.aboBloodTypeList.length; i++) {
                        if (this.aboBloodTypeList[i].name == name) { //dictValue，dictLabel保持和上面定义一致
                            return this.aboBloodTypeList[i].code;
                        }
                    }
                },

                // 获取rh血型字典
                getRhBloodType(){
                    axios.get('/rhType/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200') {
                                this.rhBloodTypeList = res.data.data
                            } else {
                                this.$notify.error({
                                    title: '错误',
                                    message: '获取数据失败',
                                })
                            }
                        })
                },

                // 将表格中rhBloodType字段的code转换成name
                getRhBloodName(code){
                    for (var i = 0; i < this.rhBloodTypeList.length; i++) {
                        if (this.rhBloodTypeList[i].code == code) { //dictValue，dictLabel保持和上面定义一致
                            return this.rhBloodTypeList[i].name;
                        }
                    }
                },

                // 将表格中的bloodComponent字段的name转换成code
                getRhBloodCode(name){
                    for (var i = 0; i < this.rhBloodTypeList.length; i++) {
                        if (this.rhBloodTypeList[i].name == name) { //dictValue，dictLabel保持和上面定义一致
                            return this.rhBloodTypeList[i].code;
                        }
                    }
                },

                // 获取血液成分字典
                getBloodComponent(){
                    axios.get('/bloodComposition/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200') {
                                this.bloodComponentList = res.data.data
                            } else {
                                this.$notify.error({
                                    title: '错误',
                                    message: '获取数据失败',
                                })
                            }
                        })
                },

                // 将表格中bloodComponent字段的code转换成name
                getBloodComponentName(code){
                    for (var i = 0; i < this.bloodComponentList.length; i++) {
                        if (this.bloodComponentList[i].code == code) { //dictValue，dictLabel保持和上面定义一致
                            return this.bloodComponentList[i].composition;
                        }
                    }
                },


                // 将表格中的bloodComponent字段的name转换成code
                getBloodComponentCode(name){
                    for (var i = 0; i < this.bloodComponentList.length; i++) {
                        if (this.bloodComponentList[i].composition == name) { //dictValue，dictLabel保持和上面定义一致
                            return this.bloodComponentList[i].code;
                        }
                    }
                },

                // 获取血液位置字典
                getBloodLocation(){
                    axios.get('/bloodLocation/normal/getName')
                        .then((res)=>{
                            if (res.data.code === '200') {
                                this.bloodLocationList = res.data.data
                            } else {
                                this.$notify.error({
                                    title: '错误',
                                    message: '获取数据失败',
                                })
                            }
                        })
                },
                // 将表格中bloodLocation字段的code转换成name
                getBloodLocationName(code){
                    for (var i = 0; i < this.bloodLocationList.length; i++) {
                        if (this.bloodLocationList[i].code == code) { //dictValue，dictLabel保持和上面定义一致
                            return this.bloodLocationList[i].location;
                        }
                    }
                },


                // 获取当前时间
                getNowTime(){
                    var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth()+1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    var minute = date.getMinutes();
                    var second = date.getSeconds();

                    var time = year + '-' + this.handleTimeStr(month) + '-' +
                        this.handleTimeStr(day) + ' ' + this.handleTimeStr(hour) + ':' + this.handleTimeStr(minute)
                        + ':' + this.handleTimeStr(second);
                    return time;
                },

                handleTimeStr(tStr){  // 解决 10:2:2 出现各位数字格式化为 10:02:02
                    if (tStr < 10){
                        return '0'+ tStr;
                    }else {
                        return tStr;
                    }
                },
            }
        });
    })()
</script>

</body>
</html>